#include "Newton.h"
#include<iostream>
#include<fstream>
using namespace std;
const double pi = acos(-1);

double func(double x)
{
	return 1 / (1 + 25 * x * x);
}

int main()
{
	const int n = 5;//n=5,10,15,20
	const int N = 101;
	double x[n + 1] = { 0 };
	double x1[N] = { 0 }, y[N] = { 0 };
	for (int i = 0; i <= n-1; i++) {
		x[i] = cos((2 * i + 1) * pi / (2 * n));
	}
	for (int i = 0; i < N; i++) {
		x1[i] = -1 + 0.02 * i;
		y[i] = newton(x, func, n, x1[i]);
	}
	ofstream ocout;
	ocout.open("c1.txt");//当n=5,10,15,20时，对应的输出文件为c1.txt,c2.txt,c3.txt,c4.txt
	for (int i = 0; i < N; i++) {
		ocout << x1[i] << " ";
		ocout << y[i] << endl;
	}
	ocout.close();
	return 0;

}
